﻿<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>顾客列表</title>
    <link href="/style/rightdirectory.css" rel="stylesheet" />
    <script src="/script/config.js"></script>
</head>
<style>
    th { text-align: center; }
    td { text-align: center; }
</style>
<body>
    <div class="view-page">
        <!--搜索区域-->
        <div class="view-search inline">
            <div class="form-inline">

                <div class="form-group col-sm-2">
                    <div class="input-group">
                        <span class="input-group-addon">真实姓名</span>
                        <input id="query" type="text" class="form-control" data-form="RealName" placeholder="真实姓名">
                    </div>
                </div>
                <div class="form-group col-sm-2">
                    <div class="input-group">
                        <span class="input-group-addon">电话</span>
                        <input id="query1" type="text" class="form-control" data-form="Phone" placeholder="电话">
                    </div>
                </div>
                <div class="form-group col-sm-2">
                    <div class="input-group">
                        <span class="input-group-addon">状态</span>
                        <input id="query2" type="text" class="form-control" data-form="Status" placeholder="状态">
                    </div>
                </div>
                <div class="form-group col-sm-2">
                    <div class="input-group">
                        <span class="input-group-addon">店铺名称</span>
                        <input id="query3" type="text" class="form-control" data-form="ShopName" placeholder="店铺名称">
                    </div>
                </div>

                <div class="form-group col-sm-1">
                    <button type="button" id="btn-search" class="btn btn-primary">
                        <i class="fa fa-search"></i> 搜索
                    </button>
                </div>
            </div>
        </div>
        <!-- 内容列表 -->
        <div class="view-data">
            <table id="table" class="table table-bordered table-hover" data-multi="">
                <thead>
                    <tr>
                        <th>
                            ID
                        </th>
                        <th>推荐人id</th>
                        <th>头像路径 </th>
                        <th>昵称 </th>
                        <th>性别 </th>                       
                        <th>描述</th>
                        <th>会员等级</th>
                        <th>收款累计</th>
                        <th>不可提</th>
                        <th>全部余额 </th>
                        <th>美豆累计 </th>
                        <th>不可提美豆 </th>
                        <th>全部美豆余额 </th>                       
                        <th>店铺名称 </th>
                        <th>创建时间</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
            <!--分页条 默认选择id=list-page元素-->
            <div id="list-page" class="view-pagination-page"></div>
        </div>
    </div>


</body>

</html>
<script type="text/html" id="tp-table">
    {{each list d}}
    <tr>
        <td><a class="detail" href="javascript:;" onclick="openDetail('{{d.Id}}')">{{d.Id}}</a></td>
        <td>{{d.ReferrerId==0?"厂家":d.ReferrerId}}</td>
        <td> <img src="{{d.Headimgurl}}" style="width:40px;height:40px;" /> </td>
        <td>{{d.Nickname}}</td>
        {{if d.Sex==1}}
        <td>男</td>
        {{else if d.Sex==2}}
        <td>女</td>
        {{else}}
        <td>未知</td>
        {{/if}}       
        <td>{{d.Remark}}</td>
        <td>{{d.VipName}}</td>
        <td>{{d.BalanceTotal}}</td>
        <td>{{d.BalanceNot}}</td>
        <td>{{d.Balance}}</td>
        <td>{{d.MeiBeanAmountTotal}}</td>
        <td>{{d.MeiBeanAmountNot}}</td>
        <td>{{d.MeiBeanAmount}}</td>
        <td>{{d.ShopName}}</td>        
        <td>{{d.CreateDate|to_date}}</td>
    </tr>
    {{/each}}
</script>

<!-- 弹出框 -->
<script type="text/html" id="tp-order-detail">
    <div id="layre-order-detail" style="padding:10px">
        <div class="panel" id="tem">
            <div class="panel-heading">顾客基本信息</div>
            <div class="panel-body">
                <table class="table table-bordered">
                    <thead>
                        <tr>
                            <th>真实姓名</th>
                            <th>头像</th>
                            <th>性别</th>
                            <th>年龄</th>
                            <th>邮箱</th>
                            <th>电话 </th>
                            <th>生日</th>
                            <th>昵称</th>
                            <th>语言 </th>
                            <th>国家</th>
                            <th>省份</th>
                            <th>城市</th>
                        </tr>
                    </thead>
                    <tbody></tbody>
                </table>
            </div>
        </div>

        <div class="panel" id="tem1">
            <div class="panel-heading">顾客购买信息</div>
            <div class="panel-body">
                <table class="table table-bordered">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>推荐人id</th>
                            <th>推荐人</th>
                            <th>会员等级Id</th>
                            <th>会员等级</th>
                            <th>收款累计 </th>
                            <th>不可提 </th>
                            <th>全部余额  </th>
                            <th>美豆累计 </th>
                            <th>不可提美豆 </th>
                            <th>全部美豆余额</th>                          
                            <th>店铺名称</th>
                            <th>描述</th>
                            <th>创建时间</th>
                        </tr>
                    </thead>
                    <tbody></tbody>
                </table>
            </div>
        </div>
    </div>
</script>

<script type="text/html" id="det-temp">
    {{set d=list[0]}}
    <tr>
        <td>{{d.RealName}}</td>
        <td> <img src="{{d.Headimgurl}}" style="width:40px;height:40px;" /> </td>
        {{if d.Sex==1}}
        <td>男</td>
        {{else if d.Sex==2}}
        <td>女</td>
        {{else}}
        <td>未知</td>
        {{/if}}
        <td>{{d.Age}}</td>
        <td>{{d.Email}}</td>
        <td>{{d.Phone}}</td>
        {{set birday=d.Birthday.substr(0,10)}}
        <td>{{birday}}</td>
        <td>{{d.Nickname}}</td>
        <td>{{d.Language}}</td>
        <td>{{d.Country}}</td>
        <td>{{d.Province}}</td>
        <td>{{d.City}}</td>

    </tr>
</script>

<script type="text/html" id="det-temp1">
    {{set d=list[0]}}
    <tr>
        <td>{{d.Id}}</td>
        <td>{{d.ReferrerId}}</td>
        <td>{{d.Referrer}}</td>
        <td>{{d.CustomerGradeConfig_Id}}</td>
        <td>{{d.VipName}}</td>
        <td>{{d.BalanceTotal}}</td>
        <td>{{d.BalanceNot}}</td>
        <td>{{d.Balance}}</td>
        <td>{{d.MeiBeanAmountTotal}}</td>
        <td>{{d.MeiBeanAmountNot}}</td>
        <td>{{d.MeiBeanAmount}}</td>
        <td>{{d.ShopName}}</td>
        <td>{{d.Remark}}</td>
        <td>{{d.CreateDate|to_date}}</td>
    </tr>
</script>


<script type="text/javascript">
    $(function () {
        function _LoadData() {
            var parm = $(".view-search").getFormData();
            $("#table").ajaxPageTable("customer/list ", parm, function (d) {
                console.log(d)
                $("#table>tbody").append(template("tp-table", {
                    list: d
                }));
            })
        }
        _LoadData();//初启化
        $("#query").focus(function () { //搜索按钮
            $("#query").keydown(function (e) {
                if (e.keyCode == 13) {
                    _LoadData();
                }
            })
        })
    
        $("#btn-search").click(function () { //搜索按钮
            _LoadData();
        })

    })

    function openDetail(o) {  //弹出订单详情
        console.log(o)
        $.layrePage({  //弹出
            area: ["90%", "800px"],
            title: "顾客列表",
            offset: "6px",
            content: template("tp-order-detail", {})
        }); 
        $.http.json("customer/find", { id: parseInt(o) }, { //发出请求
            pass: function (d) {
               
                $("#layre-order-detail #tem table>tbody").append(template("det-temp", { //订单详情
                    list: d
                }));
                $("#layre-order-detail #tem1 table>tbody").append(template("det-temp1", { //订单详情
                    list: d
                }));
            },
            error: function (d) {
                console.log(d)
            }
        })

    }
</script>

